from langchain_community.embeddings import DashScopeEmbeddings

#初始化模型
ali_embeddings = DashScopeEmbeddings(
    model="text-embedding-v2",
    max_retries=3,
    dashscope_api_key="sk-4f1498f1c0314ba79ea2919bd7a02c4d"
)

#商品的评论情感分析
comments = [
    "颜色很好看，质量不错，物流很快，值得推荐",
    "性价比高，很不错",
    "质量太差了,不满意，要退款"
]

embeddings = ali_embeddings.embed_documents(comments)
# print(embeddings)
print(len(embeddings))
one = embeddings[0]
print(one)
print(len(one))